/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package yoga.algo.phenotype;

import yoga.algo.coding.ICoding;
import yoga.algo.coding.IGenotypeCodec;

/**
 *
 * @author Yogev Montekyo
 */
public class Individual<T>
{
    protected ICoding<T> m_coding;
    protected IGenotypeCodec<T> m_genotypeCodec;

    public Individual(T type, IGenotypeCodec<T> genotypeCodec)
    {
        m_genotypeCodec = genotypeCodec;
        m_coding = genotypeCodec.encode(type);
    }

    public Individual(ICoding<T> coding, IGenotypeCodec<T> genotypeCodec)
    {
        m_genotypeCodec = genotypeCodec;
        m_coding = coding;
    }

    public T getPhenotype()
    {
        return m_genotypeCodec.decode(m_coding);
    }

    public void setPhenotype(T genotype)
    {
        m_coding = m_genotypeCodec.encode(genotype);
    }

    public ICoding<T> getCoding()
    {
        return m_coding;
    }

    public void setCoding(ICoding<T> coding)
    {
        m_coding = coding;
    }

    public IGenotypeCodec<T> getGenotypeCodec()
    {
        return m_genotypeCodec;
    }
    
//    @Override
//    public int hashCode()
//    {
//        return m_coding.getSchemataHash();
//    }
}
